/**
 *
 * \file DirParse_Win32r.h
 * \brief DirParser definition class
 * \author Edouard ROGE
 * \date 27 february 2011
 *
 */

#ifndef _DIRPARSER_WIN32_
#define _DIRPARSER_WIN32_

#include <Windows.h>
#include "URI.h"
#include "Core/Memory/HeapObject.h"

namespace Core
{
	namespace File
	{
		/**
		 * \class DirParser
		 * \brief Object which parse all file in a given directory
		 */
		class DirParser : public Memory::HeapObject
		{
		public:
			/**
			 * \fn DirParser();
			 * Default constructor
			 */
			DirParser();

			/**
			 * \fn ~DirParser();
			 * Destructor
			 */
			~DirParser();

			/**
			 * \fn const URI & GetURI() const;
			 * \return the URI of the parsed directory
			 */
			const URI & GetURI() const { return m_URI; }

			/**
			 * \fn bool Open( const String & _strURI, const String & _strExt );
			 * \param _strURI URI of the directory
			 * \param _strExt filter : keep only files with the extenstion _strExt
			 * \return true if the directory is found
			 */
			bool Open(const std::string & _strURI, const std::string & _strExt);

			/**
			 * \fn bool Close();
			 * \return true if the directory is correctly closed
			 */
			bool Close();

			/**
			 * \fn bool Iterate( String & _strFileName );
			 * \param _strFileName if found, returns the name of the next file found
			 * \return true if a file is found
			 */
			bool Iterate(std::string & _strFileName);

		private:

			/** URI of the directory */
			URI m_URI;

			/** File */
			WIN32_FIND_DATA m_File;

			/** Handle to repository */
			HANDLE m_hSearch;
		};
	}
}

#endif //_DIRPARSER_WIN32_
